home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.3 (Developer)…68k, x86, SPARC, PA-RISC] / NeXTSTEP 3.3 Dev Intel.iso / NextDeveloper / Source / GNU / cc / gcc.info-20 (.txt) < prev    next >
GNU Info File  |  1993-10-21  |  49KB  |  831 lines

  1. This is Info file gcc.info, produced by Makeinfo-1.54 from the input
  2. file gcc.texi.
  3.    This file documents the use and the internals of the GNU compiler.
  4.    Published by the Free Software Foundation 675 Massachusetts Avenue
  5. Cambridge, MA 02139 USA
  6.    Copyright (C) 1988, 1989, 1992, 1993 Free Software Foundation, Inc.
  7.    Permission is granted to make and distribute verbatim copies of this
  8. manual provided the copyright notice and this permission notice are
  9. preserved on all copies.
  10.    Permission is granted to copy and distribute modified versions of
  11. this manual under the conditions for verbatim copying, provided also
  12. that the sections entitled "GNU General Public License" and "Protect
  13. Your Freedom--Fight `Look And Feel'" are included exactly as in the
  14. original, and provided that the entire resulting derived work is
  15. distributed under the terms of a permission notice identical to this
  16.    Permission is granted to copy and distribute translations of this
  17. manual into another language, under the above conditions for modified
  18. versions, except that the sections entitled "GNU General Public
  19. License" and "Protect Your Freedom--Fight `Look And Feel'", and this
  20. permission notice, may be included in translations approved by the Free
  21. Software Foundation instead of in the original English.
  22. File: gcc.info,  Node: Condition Code,  Next: Costs,  Prev: Addressing Modes,  Up: Target Macros
  23. Condition Code Status
  24. =====================
  25.    The file `conditions.h' defines a variable `cc_status' to describe
  26. how the condition code was computed (in case the interpretation of the
  27. condition code depends on the instruction that it was set by).  This
  28. variable contains the RTL expressions on which the condition code is
  29. currently based, and several standard flags.
  30.    Sometimes additional machine-specific flags must be defined in the
  31. machine description header file.  It can also add additional
  32. machine-specific information by defining `CC_STATUS_MDEP'.
  33. `CC_STATUS_MDEP'
  34.      C code for a data type which is used for declaring the `mdep'
  35.      component of `cc_status'.  It defaults to `int'.
  36.      This macro is not used on machines that do not use `cc0'.
  37. `CC_STATUS_MDEP_INIT'
  38.      A C expression to initialize the `mdep' field to "empty".  The
  39.      default definition does nothing, since most machines don't use the
  40.      field anyway.  If you want to use the field, you should probably
  41.      define this macro to initialize it.
  42.      This macro is not used on machines that do not use `cc0'.
  43. `NOTICE_UPDATE_CC (EXP, INSN)'
  44.      A C compound statement to set the components of `cc_status'
  45.      appropriately for an insn INSN whose body is EXP.  It is this
  46.      macro's responsibility to recognize insns that set the condition
  47.      code as a byproduct of other activity as well as those that
  48.      explicitly set `(cc0)'.
  49.      This macro is not used on machines that do not use `cc0'.
  50.      If there are insns that do not set the condition code but do alter
  51.      other machine registers, this macro must check to see whether they
  52.      invalidate the expressions that the condition code is recorded as
  53.      reflecting.  For example, on the 68000, insns that store in address
  54.      registers do not set the condition code, which means that usually
  55.      `NOTICE_UPDATE_CC' can leave `cc_status' unaltered for such insns.
  56.      But suppose that the previous insn set the condition code based
  57.      on location `a4@(102)' and the current insn stores a new value in
  58.      `a4'.  Although the condition code is not changed by this, it will
  59.      no longer be true that it reflects the contents of `a4@(102)'.
  60.      Therefore, `NOTICE_UPDATE_CC' must alter `cc_status' in this case
  61.      to say that nothing is known about the condition code value.
  62.      The definition of `NOTICE_UPDATE_CC' must be prepared to deal with
  63.      the results of peephole optimization: insns whose patterns are
  64.      `parallel' RTXs containing various `reg', `mem' or constants which
  65.      are just the operands.  The RTL structure of these insns is not
  66.      sufficient to indicate what the insns actually do.  What
  67.      `NOTICE_UPDATE_CC' should do when it sees one is just to run
  68.      `CC_STATUS_INIT'.
  69.      A possible definition of `NOTICE_UPDATE_CC' is to call a function
  70.      that looks at an attribute (*note Insn Attributes::.) named, for
  71.      example, `cc'.  This avoids having detailed information about
  72.      patterns in two places, the `md' file and in `NOTICE_UPDATE_CC'.
  73. `EXTRA_CC_MODES'
  74.      A list of names to be used for additional modes for condition code
  75.      values in registers (*note Jump Patterns::.).  These names are
  76.      added to `enum machine_mode' and all have class `MODE_CC'.  By
  77.      convention, they should start with `CC' and end with `mode'.
  78.      You should only define this macro if your machine does not use
  79.      `cc0' and only if additional modes are required.
  80. `EXTRA_CC_NAMES'
  81.      A list of C strings giving the names for the modes listed in
  82.      `EXTRA_CC_MODES'.  For example, the Sparc defines this macro and
  83.      `EXTRA_CC_MODES' as
  84.           #define EXTRA_CC_MODES CC_NOOVmode, CCFPmode
  85.           #define EXTRA_CC_NAMES "CC_NOOV", "CCFP"
  86.      This macro is not required if `EXTRA_CC_MODES' is not defined.
  87. `SELECT_CC_MODE (OP, X, Y)'
  88.      Returns a mode from class `MODE_CC' to be used when comparison
  89.      operation code OP is applied to rtx X and Y.  For example, on the
  90.      Sparc, `SELECT_CC_MODE' is defined as (see *note Jump Patterns::.
  91.      for a description of the reason for this definition)
  92.           #define SELECT_CC_MODE(OP,X,Y) \
  93.             (GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT          \
  94.              ? ((OP == EQ || OP == NE) ? CCFPmode : CCFPEmode)    \
  95.              : ((GET_CODE (X) == PLUS || GET_CODE (X) == MINUS    \
  96.                  || GET_CODE (X) == NEG) \
  97.                 ? CC_NOOVmode : CCmode))
  98.      This macro is not required if `EXTRA_CC_MODES' is not defined.
  99. File: gcc.info,  Node: Costs,  Next: Sections,  Prev: Condition Code,  Up: Target Macros
  100. Describing Relative Costs of Operations
  101. =======================================
  102.    These macros let you describe the relative speed of various
  103. operations on the target machine.
  104. `CONST_COSTS (X, CODE, OUTER_CODE)'
  105.      A part of a C `switch' statement that describes the relative costs
  106.      of constant RTL expressions.  It must contain `case' labels for
  107.      expression codes `const_int', `const', `symbol_ref', `label_ref'
  108.      and `const_double'.  Each case must ultimately reach a `return'
  109.      statement to return the relative cost of the use of that kind of
  110.      constant value in an expression.  The cost may depend on the
  111.      precise value of the constant, which is available for examination
  112.      in X, and the rtx code of the expression in which it is contained,
  113.      found in OUTER_CODE.
  114.      CODE is the expression code--redundant, since it can be obtained
  115.      with `GET_CODE (X)'.
  116. `RTX_COSTS (X, CODE, OUTER_CODE)'
  117.      Like `CONST_COSTS' but applies to nonconstant RTL expressions.
  118.      This can be used, for example, to indicate how costly a multiply
  119.      instruction is.  In writing this macro, you can use the construct
  120.      `COSTS_N_INSNS (N)' to specify a cost equal to N fast
  121.      instructions.  OUTER_CODE is the code of the expression in which X
  122.      is contained.
  123.      This macro is optional; do not define it if the default cost
  124.      assumptions are adequate for the target machine.
  125. `ADDRESS_COST (ADDRESS)'
  126.      An expression giving the cost of an addressing mode that contains
  127.      ADDRESS.  If not defined, the cost is computed from the ADDRESS
  128.      expression and the `CONST_COSTS' values.
  129.      For most CISC machines, the default cost is a good approximation
  130.      of the true cost of the addressing mode.  However, on RISC
  131.      machines, all instructions normally have the same length and
  132.      execution time.  Hence all addresses will have equal costs.
  133.      In cases where more than one form of an address is known, the form
  134.      with the lowest cost will be used.  If multiple forms have the
  135.      same, lowest, cost, the one that is the most complex will be used.
  136.      For example, suppose an address that is equal to the sum of a
  137.      register and a constant is used twice in the same basic block.
  138.      When this macro is not defined, the address will be computed in a
  139.      register and memory references will be indirect through that
  140.      register.  On machines where the cost of the addressing mode
  141.      containing the sum is no higher than that of a simple indirect
  142.      reference, this will produce an additional instruction and
  143.      possibly require an additional register.  Proper specification of
  144.      this macro eliminates this overhead for such machines.
  145.      Similar use of this macro is made in strength reduction of loops.
  146.      ADDRESS need not be valid as an address.  In such a case, the cost
  147.      is not relevant and can be any value; invalid addresses need not be
  148.      assigned a different cost.
  149.      On machines where an address involving more than one register is as
  150.      cheap as an address computation involving only one register,
  151.      defining `ADDRESS_COST' to reflect this can cause two registers to
  152.      be live over a region of code where only one would have been if
  153.      `ADDRESS_COST' were not defined in that manner.  This effect should
  154.      be considered in the definition of this macro.  Equivalent costs
  155.      should probably only be given to addresses with different numbers
  156.      of registers on machines with lots of registers.
  157.      This macro will normally either not be defined or be defined as a
  158.      constant.
  159. `REGISTER_MOVE_COST (FROM, TO)'
  160.      A C expression for the cost of moving data from a register in class
  161.      FROM to one in class TO.  The classes are expressed using the
  162.      enumeration values such as `GENERAL_REGS'.  A value of 4 is the
  163.      default; other values are interpreted relative to that.
  164.      It is not required that the cost always equal 2 when FROM is the
  165.      same as TO; on some machines it is expensive to move between
  166.      registers if they are not general registers.
  167.      If reload sees an insn consisting of a single `set' between two
  168.      hard registers, and if `REGISTER_MOVE_COST' applied to their
  169.      classes returns a value of 2, reload does not check to ensure that
  170.      the constraints of the insn are met.  Setting a cost of other than
  171.      2 will allow reload to verify that the constraints are met.  You
  172.      should do this if the `movM' pattern's constraints do not allow
  173.      such copying.
  174. `MEMORY_MOVE_COST (M)'
  175.      A C expression for the cost of moving data of mode M between a
  176.      register and memory.  A value of 2 is the default; this cost is
  177.      relative to those in `REGISTER_MOVE_COST'.
  178.      If moving between registers and memory is more expensive than
  179.      between two registers, you should define this macro to express the
  180.      relative cost.
  181. `BRANCH_COST'
  182.      A C expression for the cost of a branch instruction.  A value of 1
  183.      is the default; other values are interpreted relative to that.
  184.    Here are additional macros which do not specify precise relative
  185. costs, but only that certain actions are more expensive than GNU CC
  186. would ordinarily expect.
  187. `SLOW_BYTE_ACCESS'
  188.      Define this macro as a C expression which is nonzero if accessing
  189.      less than a word of memory (i.e. a `char' or a `short') is no
  190.      faster than accessing a word of memory, i.e., if such access
  191.      require more than one instruction or if there is no difference in
  192.      cost between byte and (aligned) word loads.
  193.      When this macro is not defined, the compiler will access a field by
  194.      finding the smallest containing object; when it is defined, a
  195.      fullword load will be used if alignment permits.  Unless bytes
  196.      accesses are faster than word accesses, using word accesses is
  197.      preferable since it may eliminate subsequent memory access if
  198.      subsequent accesses occur to other fields in the same word of the
  199.      structure, but to different bytes.
  200. `SLOW_ZERO_EXTEND'
  201.      Define this macro if zero-extension (of a `char' or `short' to an
  202.      `int') can be done faster if the destination is a register that is
  203.      known to be zero.
  204.      If you define this macro, you must have instruction patterns that
  205.      recognize RTL structures like this:
  206.           (set (strict_low_part (subreg:QI (reg:SI ...) 0)) ...)
  207.      and likewise for `HImode'.
  208. `SLOW_UNALIGNED_ACCESS'
  209.      Define this macro to be the value 1 if unaligned accesses have a
  210.      cost many times greater than aligned accesses, for example if they
  211.      are emulated in a trap handler.
  212.      When this macro is non-zero, the compiler will act as if
  213.      `STRICT_ALIGNMENT' were non-zero when generating code for block
  214.      moves.  This can cause significantly more instructions to be
  215.      produced.  Therefore, do not set this macro non-zero if unaligned
  216.      accesses only add a cycle or two to the time for a memory access.
  217.      If the value of this macro is always zero, it need not be defined.
  218. `DONT_REDUCE_ADDR'
  219.      Define this macro to inhibit strength reduction of memory
  220.      addresses.  (On some machines, such strength reduction seems to do
  221.      harm rather than good.)
  222. `MOVE_RATIO'
  223.      The number of scalar move insns which should be generated instead
  224.      of a string move insn or a library call.  Increasing the value
  225.      will always make code faster, but eventually incurs high cost in
  226.      increased code size.
  227.      If you don't define this, a reasonable default is used.
  228. `NO_FUNCTION_CSE'
  229.      Define this macro if it is as good or better to call a constant
  230.      function address than to call an address kept in a register.
  231. `NO_RECURSIVE_FUNCTION_CSE'
  232.      Define this macro if it is as good or better for a function to call
  233.      itself with an explicit address than to call an address kept in a
  234.      register.
  235. `ADJUST_COST (INSN, LINK, DEP_INSN, COST)'
  236.      A C statement (sans semicolon) to update the integer variable COST
  237.      based on the relationship between INSN that is dependent on
  238.      DEP_INSN through the dependence LINK.  The default is to make no
  239.      adjustment to COST.  This can be used for example to specify to
  240.      the scheduler that an output- or anti-dependence does not incur
  241.      the same cost as a data-dependence.
  242. File: gcc.info,  Node: Sections,  Next: PIC,  Prev: Costs,  Up: Target Macros
  243. Dividing the Output into Sections (Texts, Data, ...)
  244. ====================================================
  245.    An object file is divided into sections containing different types of
  246. data.  In the most common case, there are three sections: the "text
  247. section", which holds instructions and read-only data; the "data
  248. section", which holds initialized writable data; and the "bss section",
  249. which holds uninitialized data.  Some systems have other kinds of
  250. sections.
  251.    The compiler must tell the assembler when to switch sections.  These
  252. macros control what commands to output to tell the assembler this.  You
  253. can also define additional sections.
  254. `TEXT_SECTION_ASM_OP'
  255.      A C expression whose value is a string containing the assembler
  256.      operation that should precede instructions and read-only data.
  257.      Normally `".text"' is right.
  258. `DATA_SECTION_ASM_OP'
  259.      A C expression whose value is a string containing the assembler
  260.      operation to identify the following data as writable initialized
  261.      data.  Normally `".data"' is right.
  262. `SHARED_SECTION_ASM_OP'
  263.      if defined, a C expression whose value is a string containing the
  264.      assembler operation to identify the following data as shared data.
  265.      If not defined, `DATA_SECTION_ASM_OP' will be used.
  266. `INIT_SECTION_ASM_OP'
  267.      if defined, a C expression whose value is a string containing the
  268.      assembler operation to identify the following data as
  269.      initialization code.  If not defined, GNU CC will assume such a
  270.      section does not exist.
  271. `EXTRA_SECTIONS'
  272.      A list of names for sections other than the standard two, which are
  273.      `in_text' and `in_data'.  You need not define this macro on a
  274.      system with no other sections (that GCC needs to use).
  275. `EXTRA_SECTION_FUNCTIONS'
  276.      One or more functions to be defined in `varasm.c'.  These
  277.      functions should do jobs analogous to those of `text_section' and
  278.      `data_section', for your additional sections.  Do not define this
  279.      macro if you do not define `EXTRA_SECTIONS'.
  280. `READONLY_DATA_SECTION'
  281.      On most machines, read-only variables, constants, and jump tables
  282.      are placed in the text section.  If this is not the case on your
  283.      machine, this macro should be defined to be the name of a function
  284.      (either `data_section' or a function defined in `EXTRA_SECTIONS')
  285.      that switches to the section to be used for read-only items.
  286.      If these items should be placed in the text section, this macro
  287.      should not be defined.
  288. `SELECT_SECTION (EXP, RELOC)'
  289.      A C statement or statements to switch to the appropriate section
  290.      for output of EXP.  You can assume that EXP is either a `VAR_DECL'
  291.      node or a constant of some sort.  RELOC indicates whether the
  292.      initial value of EXP requires link-time relocations.  Select the
  293.      section by calling `text_section' or one of the alternatives for
  294.      other sections.
  295.      Do not define this macro if you put all read-only variables and
  296.      constants in the read-only data section (usually the text section).
  297. `SELECT_RTX_SECTION (MODE, RTX)'
  298.      A C statement or statements to switch to the appropriate section
  299.      for output of RTX in mode MODE.  You can assume that RTX is some
  300.      kind of constant in RTL.  The argument MODE is redundant except in
  301.      the case of a `const_int' rtx.  Select the section by calling
  302.      `text_section' or one of the alternatives for other sections.
  303.      Do not define this macro if you put all constants in the read-only
  304.      data section.
  305. `JUMP_TABLES_IN_TEXT_SECTION'
  306.      Define this macro if jump tables (for `tablejump' insns) should be
  307.      output in the text section, along with the assembler instructions.
  308.      Otherwise, the readonly data section is used.
  309.      This macro is irrelevant if there is no separate readonly data
  310.      section.
  311. `ENCODE_SECTION_INFO (DECL)'
  312.      Define this macro if references to a symbol must be treated
  313.      differently depending on something about the variable or function
  314.      named by the symbol (such as what section it is in).
  315.      The macro definition, if any, is executed immediately after the
  316.      rtl for DECL has been created and stored in `DECL_RTL (DECL)'.
  317.      The value of the rtl will be a `mem' whose address is a
  318.      `symbol_ref'.
  319.      The usual thing for this macro to do is to record a flag in the
  320.      `symbol_ref' (such as `SYMBOL_REF_FLAG') or to store a modified
  321.      name string in the `symbol_ref' (if one bit is not enough
  322.      information).
  323. `STRIP_NAME_ENCODING (VAR, SYM_NAME)'
  324.      Decode SYM_NAME and store the real name part in VAR, sans the
  325.      characters that encode section info.  Define this macro if
  326.      `ENCODE_SECTION_INFO' alters the symbol's name string.
  327. File: gcc.info,  Node: PIC,  Next: Assembler Format,  Prev: Sections,  Up: Target Macros
  328. Position Independent Code
  329. =========================
  330.    This section describes macros that help implement generation of
  331. position independent code.  Simply defining these macros is not enough
  332. to generate valid PIC; you must also add support to the macros
  333. `GO_IF_LEGITIMATE_ADDRESS' and `PRINT_OPERAND_ADDRESS', as well as
  334. `LEGITIMIZE_ADDRESS'.  You must modify the definition of `movsi' to do
  335. something appropriate when the source operand contains a symbolic
  336. address.  You may also need to alter the handling of switch statements
  337. so that they use relative addresses.
  338. `PIC_OFFSET_TABLE_REGNUM'
  339.      The register number of the register used to address a table of
  340.      static data addresses in memory.  In some cases this register is
  341.      defined by a processor's "application binary interface" (ABI).
  342.      When this macro is defined, RTL is generated for this register
  343.      once, as with the stack pointer and frame pointer registers.  If
  344.      this macro is not defined, it is up to the machine-dependent files
  345.      to allocate such a register (if necessary).
  346. `FINALIZE_PIC'
  347.      By generating position-independent code, when two different
  348.      programs (A and B) share a common library (libC.a), the text of
  349.      the library can be shared whether or not the library is linked at
  350.      the same address for both programs.  In some of these
  351.      environments, position-independent code requires not only the use
  352.      of different addressing modes, but also special code to enable the
  353.      use of these addressing modes.
  354.      The `FINALIZE_PIC' macro serves as a hook to emit these special
  355.      codes once the function is being compiled into assembly code, but
  356.      not before.  (It is not done before, because in the case of
  357.      compiling an inline function, it would lead to multiple PIC
  358.      prologues being included in functions which used inline functions
  359.      and were compiled to assembly language.)
  360. `LEGITIMATE_PIC_OPERAND_P (X)'
  361.      A C expression that is nonzero if X is a legitimate immediate
  362.      operand on the target machine when generating position independent
  363.      code.  You can assume that X satisfies `CONSTANT_P', so you need
  364.      not check this.  You can also assume FLAG_PIC is true, so you need
  365.      not check it either.  You need not define this macro if all
  366.      constants (including `SYMBOL_REF') can be immediate operands when
  367.      generating position independent code.
  368. File: gcc.info,  Node: Assembler Format,  Next: Debugging Info,  Prev: PIC,  Up: Target Macros
  369. Defining the Output Assembler Language
  370. ======================================
  371.    This section describes macros whose principal purpose is to describe
  372. how to write instructions in assembler language-rather than what the
  373. instructions do.
  374. * Menu:
  375. * File Framework::       Structural information for the assembler file.
  376. * Data Output::          Output of constants (numbers, strings, addresses).
  377. * Uninitialized Data::   Output of uninitialized variables.
  378. * Label Output::         Output and generation of labels.
  379. * Initialization::       General principles of initialization
  380.                and termination routines.
  381. * Macros for Initialization::
  382.              Specific macros that control the handling of
  383.                initialization and termination routines.
  384. * Instruction Output::   Output of actual instructions.
  385. * Dispatch Tables::      Output of jump tables.
  386. * Alignment Output::     Pseudo ops for alignment and skipping data.
  387. File: gcc.info,  Node: File Framework,  Next: Data Output,  Up: Assembler Format
  388. The Overall Framework of an Assembler File
  389. ------------------------------------------
  390. `ASM_FILE_START (STREAM)'
  391.      A C expression which outputs to the stdio stream STREAM some
  392.      appropriate text to go at the start of an assembler file.
  393.      Normally this macro is defined to output a line containing
  394.      `#NO_APP', which is a comment that has no effect on most
  395.      assemblers but tells the GNU assembler that it can save time by not
  396.      checking for certain assembler constructs.
  397.      On systems that use SDB, it is necessary to output certain
  398.      commands; see `attasm.h'.
  399. `ASM_FILE_END (STREAM)'
  400.      A C expression which outputs to the stdio stream STREAM some
  401.      appropriate text to go at the end of an assembler file.
  402.      If this macro is not defined, the default is to output nothing
  403.      special at the end of the file.  Most systems don't require any
  404.      definition.
  405.      On systems that use SDB, it is necessary to output certain
  406.      commands; see `attasm.h'.
  407. `ASM_IDENTIFY_GCC (FILE)'
  408.      A C statement to output assembler commands which will identify the
  409.      object file as having been compiled with GNU CC (or another GNU
  410.      compiler).
  411.      If you don't define this macro, the string `gcc_compiled.:' is
  412.      output.  This string is calculated to define a symbol which, on
  413.      BSD systems, will never be defined for any other reason.  GDB
  414.      checks for the presence of this symbol when reading the symbol
  415.      table of an executable.
  416.      On non-BSD systems, you must arrange communication with GDB in
  417.      some other fashion.  If GDB is not used on your system, you can
  418.      define this macro with an empty body.
  419. `ASM_COMMENT_START'
  420.      A C string constant describing how to begin a comment in the target
  421.      assembler language.  The compiler assumes that the comment will
  422.      end at the end of the line.
  423. `ASM_APP_ON'
  424.      A C string constant for text to be output before each `asm'
  425.      statement or group of consecutive ones.  Normally this is
  426.      `"#APP"', which is a comment that has no effect on most assemblers
  427.      but tells the GNU assembler that it must check the lines that
  428.      follow for all valid assembler constructs.
  429. `ASM_APP_OFF'
  430.      A C string constant for text to be output after each `asm'
  431.      statement or group of consecutive ones.  Normally this is
  432.      `"#NO_APP"', which tells the GNU assembler to resume making the
  433.      time-saving assumptions that are valid for ordinary compiler
  434.      output.
  435. `ASM_OUTPUT_SOURCE_FILENAME (STREAM, NAME)'
  436.      A C statement to output COFF information or DWARF debugging
  437.      information which indicates that filename NAME is the current
  438.      source file to the stdio stream STREAM.
  439.      This macro need not be defined if the standard form of output for
  440.      the file format in use is appropriate.
  441. `ASM_OUTPUT_SOURCE_LINE (STREAM, LINE)'
  442.      A C statement to output DBX or SDB debugging information before
  443.      code for line number LINE of the current source file to the stdio
  444.      stream STREAM.
  445.      This macro need not be defined if the standard form of debugging
  446.      information for the debugger in use is appropriate.
  447. `ASM_OUTPUT_IDENT (STREAM, STRING)'
  448.      A C statement to output something to the assembler file to handle a
  449.      `#ident' directive containing the text STRING.  If this macro is
  450.      not defined, nothing is output for a `#ident' directive.
  451. `OBJC_PROLOGUE'
  452.      A C statement to output any assembler statements which are
  453.      required to precede any Objective C object definitions or message
  454.      sending.  The statement is executed only when compiling an
  455.      Objective C program.
  456. File: gcc.info,  Node: Data Output,  Next: Uninitialized Data,  Prev: File Framework,  Up: Assembler Format
  457. Output of Data
  458. --------------
  459. `ASM_OUTPUT_LONG_DOUBLE (STREAM, VALUE)'
  460. `ASM_OUTPUT_DOUBLE (STREAM, VALUE)'
  461. `ASM_OUTPUT_FLOAT (STREAM, VALUE)'
  462.      A C statement to output to the stdio stream STREAM an assembler
  463.      instruction to assemble a floating-point constant of `TFmode',
  464.      `DFmode' or `SFmode', respectively, whose value is VALUE.  VALUE
  465.      will be a C expression of type `REAL_VALUE_TYPE'.  Macros such as
  466.      `REAL_VALUE_TO_TARGET_DOUBLE' are useful for writing these
  467.      definitions.
  468. `ASM_OUTPUT_QUADRUPLE_INT (STREAM, EXP)'
  469. `ASM_OUTPUT_DOUBLE_INT (STREAM, EXP)'
  470. `ASM_OUTPUT_INT (STREAM, EXP)'
  471. `ASM_OUTPUT_SHORT (STREAM, EXP)'
  472. `ASM_OUTPUT_CHAR (STREAM, EXP)'
  473.      A C statement to output to the stdio stream STREAM an assembler
  474.      instruction to assemble an integer of 16, 8, 4, 2 or 1 bytes,
  475.      respectively, whose value is VALUE.  The argument EXP will be an
  476.      RTL expression which represents a constant value.  Use
  477.      `output_addr_const (STREAM, EXP)' to output this value as an
  478.      assembler expression.
  479.      For sizes larger than `UNITS_PER_WORD', if the action of a macro
  480.      would be identical to repeatedly calling the macro corresponding to
  481.      a size of `UNITS_PER_WORD', once for each word, you need not define
  482.      the macro.
  483. `ASM_OUTPUT_BYTE (STREAM, VALUE)'
  484.      A C statement to output to the stdio stream STREAM an assembler
  485.      instruction to assemble a single byte containing the number VALUE.
  486. `ASM_BYTE_OP'
  487.      A C string constant giving the pseudo-op to use for a sequence of
  488.      single-byte constants.  If this macro is not defined, the default
  489.      is `"byte"'.
  490. `ASM_OUTPUT_ASCII (STREAM, PTR, LEN)'
  491.      A C statement to output to the stdio stream STREAM an assembler
  492.      instruction to assemble a string constant containing the LEN bytes
  493.      at PTR.  PTR will be a C expression of type `char *' and LEN a C
  494.      expression of type `int'.
  495.      If the assembler has a `.ascii' pseudo-op as found in the Berkeley
  496.      Unix assembler, do not define the macro `ASM_OUTPUT_ASCII'.
  497. `ASM_OUTPUT_POOL_PROLOGUE (FILE FUNNAME FUNDECL SIZE)'
  498.      A C statement to output assembler commands to define the start of
  499.      the constant pool for a function.  FUNNAME is a string giving the
  500.      name of the function.  Should the return type of the function be
  501.      required, it can be obtained via FUNDECL.  SIZE is the size, in
  502.      bytes, of the constant pool that will be written immediately after
  503.      this call.
  504.      If no constant-pool prefix is required, the usual case, this macro
  505.      need not be defined.
  506. `ASM_OUTPUT_SPECIAL_POOL_ENTRY (FILE, X, MODE, ALIGN, LABELNO, JUMPTO)'
  507.      A C statement (with or without semicolon) to output a constant in
  508.      the constant pool, if it needs special treatment.  (This macro
  509.      need not do anything for RTL expressions that can be output
  510.      normally.)
  511.      The argument FILE is the standard I/O stream to output the
  512.      assembler code on.  X is the RTL expression for the constant to
  513.      output, and MODE is the machine mode (in case X is a `const_int').
  514.      ALIGN is the required alignment for the value X; you should
  515.      output an assembler directive to force this much alignment.
  516.      The argument LABELNO is a number to use in an internal label for
  517.      the address of this pool entry.  The definition of this macro is
  518.      responsible for outputting the label definition at the proper
  519.      place.  Here is how to do this:
  520.           ASM_OUTPUT_INTERNAL_LABEL (FILE, "LC", LABELNO);
  521.      When you output a pool entry specially, you should end with a
  522.      `goto' to the label JUMPTO.  This will prevent the same pool entry
  523.      from being output a second time in the usual manner.
  524.      You need not define this macro if it would do nothing.
  525. `ASM_OPEN_PAREN'
  526. `ASM_CLOSE_PAREN'
  527.      These macros are defined as C string constant, describing the
  528.      syntax in the assembler for grouping arithmetic expressions.  The
  529.      following definitions are correct for most assemblers:
  530.           #define ASM_OPEN_PAREN "("
  531.           #define ASM_CLOSE_PAREN ")"
  532.    These macros are provided by `real.h' for writing the definitions of
  533. `ASM_OUTPUT_DOUBLE' and the like:
  534. `REAL_VALUE_TO_TARGET_SINGLE (X, L)'
  535. `REAL_VALUE_TO_TARGET_DOUBLE (X, L)'
  536. `REAL_VALUE_TO_TARGET_LONG_DOUBLE (X, L)'
  537.      These translate X, of type `REAL_VALUE_TYPE', to the target's
  538.      floating point representation, and store its bit pattern in the
  539.      array of `long int' whose address is L.  The number of elements in
  540.      the output array is determined by the size of the desired target
  541.      floating point data type: 32 bits of it go in each `long int' array
  542.      element.  Each array element holds 32 bits of the result, even if
  543.      `long int' is wider than 32 bits on the host machine.
  544.      The array element values are designed so that you can print them
  545.      out using `fprintf' in the order they should appear in the target
  546.      machine's memory.
  547. `REAL_VALUE_TO_DECIMAL (X, FORMAT, STRING)'
  548.      This macro converts X, of type `REAL_VALUE_TYPE', to a decimal
  549.      number and stores it as a string into STRING.  You must pass, as
  550.      STRING, the address of a long enough block of space to hold the
  551.      result.
  552.      The argument FORMAT is a `printf'-specification that serves as a
  553.      suggestion for how to format the output string.
  554. File: gcc.info,  Node: Uninitialized Data,  Next: Label Output,  Prev: Data Output,  Up: Assembler Format
  555. Output of Uninitialized Variables
  556. ---------------------------------
  557.    Each of the macros in this section is used to do the whole job of
  558. outputting a single uninitialized variable.
  559. `ASM_OUTPUT_COMMON (STREAM, NAME, SIZE, ROUNDED)'
  560.      A C statement (sans semicolon) to output to the stdio stream
  561.      STREAM the assembler definition of a common-label named NAME whose
  562.      size is SIZE bytes.  The variable ROUNDED is the size rounded up
  563.      to whatever alignment the caller wants.
  564.      Use the expression `assemble_name (STREAM, NAME)' to output the
  565.      name itself; before and after that, output the additional
  566.      assembler syntax for defining the name, and a newline.
  567.      This macro controls how the assembler definitions of uninitialized
  568.      global variables are output.
  569. `ASM_OUTPUT_ALIGNED_COMMON (STREAM, NAME, SIZE, ALIGNMENT)'
  570.      Like `ASM_OUTPUT_COMMON' except takes the required alignment as a
  571.      separate, explicit argument.  If you define this macro, it is used
  572.      in place of `ASM_OUTPUT_COMMON', and gives you more flexibility in
  573.      handling the required alignment of the variable.
  574. `ASM_OUTPUT_SHARED_COMMON (STREAM, NAME, SIZE, ROUNDED)'
  575.      If defined, it is similar to `ASM_OUTPUT_COMMON', except that it
  576.      is used when NAME is shared.  If not defined, `ASM_OUTPUT_COMMON'
  577.      will be used.
  578. `ASM_OUTPUT_LOCAL (STREAM, NAME, SIZE, ROUNDED)'
  579.      A C statement (sans semicolon) to output to the stdio stream
  580.      STREAM the assembler definition of a local-common-label named NAME
  581.      whose size is SIZE bytes.  The variable ROUNDED is the size
  582.      rounded up to whatever alignment the caller wants.
  583.      Use the expression `assemble_name (STREAM, NAME)' to output the
  584.      name itself; before and after that, output the additional
  585.      assembler syntax for defining the name, and a newline.
  586.      This macro controls how the assembler definitions of uninitialized
  587.      static variables are output.
  588. `ASM_OUTPUT_ALIGNED_LOCAL (STREAM, NAME, SIZE, ALIGNMENT)'
  589.      Like `ASM_OUTPUT_LOCAL' except takes the required alignment as a
  590.      separate, explicit argument.  If you define this macro, it is used
  591.      in place of `ASM_OUTPUT_LOCAL', and gives you more flexibility in
  592.      handling the required alignment of the variable.
  593. `ASM_OUTPUT_SHARED_LOCAL (STREAM, NAME, SIZE, ROUNDED)'
  594.      If defined, it is similar to `ASM_OUTPUT_LOCAL', except that it is
  595.      used when NAME is shared.  If not defined, `ASM_OUTPUT_LOCAL' will
  596.      be used.
  597. File: gcc.info,  Node: Label Output,  Next: Initialization,  Prev: Uninitialized Data,  Up: Assembler Format
  598. Output and Generation of Labels
  599. -------------------------------
  600. `ASM_OUTPUT_LABEL (STREAM, NAME)'
  601.      A C statement (sans semicolon) to output to the stdio stream
  602.      STREAM the assembler definition of a label named NAME.  Use the
  603.      expression `assemble_name (STREAM, NAME)' to output the name
  604.      itself; before and after that, output the additional assembler
  605.      syntax for defining the name, and a newline.
  606. `ASM_DECLARE_FUNCTION_NAME (STREAM, NAME, DECL)'
  607.      A C statement (sans semicolon) to output to the stdio stream
  608.      STREAM any text necessary for declaring the name NAME of a
  609.      function which is being defined.  This macro is responsible for
  610.      outputting the label definition (perhaps using
  611.      `ASM_OUTPUT_LABEL').  The argument DECL is the `FUNCTION_DECL'
  612.      tree node representing the function.
  613.      If this macro is not defined, then the function name is defined in
  614.      the usual manner as a label (by means of `ASM_OUTPUT_LABEL').
  615. `ASM_DECLARE_FUNCTION_SIZE (STREAM, NAME, DECL)'
  616.      A C statement (sans semicolon) to output to the stdio stream
  617.      STREAM any text necessary for declaring the size of a function
  618.      which is being defined.  The argument NAME is the name of the
  619.      function.  The argument DECL is the `FUNCTION_DECL' tree node
  620.      representing the function.
  621.      If this macro is not defined, then the function size is not
  622.      defined.
  623. `ASM_DECLARE_OBJECT_NAME (STREAM, NAME, DECL)'
  624.      A C statement (sans semicolon) to output to the stdio stream
  625.      STREAM any text necessary for declaring the name NAME of an
  626.      initialized variable which is being defined.  This macro must
  627.      output the label definition (perhaps using `ASM_OUTPUT_LABEL').
  628.      The argument DECL is the `VAR_DECL' tree node representing the
  629.      variable.
  630.      If this macro is not defined, then the variable name is defined in
  631.      the usual manner as a label (by means of `ASM_OUTPUT_LABEL').
  632. `ASM_FINISH_DECLARE_OBJECT (STREAM, DECL, TOPLEVEL, ATEND)'
  633.      A C statement (sans semicolon) to finish up declaring a variable
  634.      name once the compiler has processed its initializer fully and
  635.      thus has had a chance to determine the size of an array when
  636.      controlled by an initializer.  This is used on systems where it's
  637.      necessary to declare something about the size of the object.
  638.      If you don't define this macro, that is equivalent to defining it
  639.      to do nothing.
  640. `ASM_GLOBALIZE_LABEL (STREAM, NAME)'
  641.      A C statement (sans semicolon) to output to the stdio stream
  642.      STREAM some commands that will make the label NAME global; that
  643.      is, available for reference from other files.  Use the expression
  644.      `assemble_name (STREAM, NAME)' to output the name itself; before
  645.      and after that, output the additional assembler syntax for making
  646.      that name global, and a newline.
  647. `ASM_OUTPUT_EXTERNAL (STREAM, DECL, NAME)'
  648.      A C statement (sans semicolon) to output to the stdio stream
  649.      STREAM any text necessary for declaring the name of an external
  650.      symbol named NAME which is referenced in this compilation but not
  651.      defined.  The value of DECL is the tree node for the declaration.
  652.      This macro need not be defined if it does not need to output
  653.      anything.  The GNU assembler and most Unix assemblers don't
  654.      require anything.
  655. `ASM_OUTPUT_EXTERNAL_LIBCALL (STREAM, SYMREF)'
  656.      A C statement (sans semicolon) to output on STREAM an assembler
  657.      pseudo-op to declare a library function name external.  The name
  658.      of the library function is given by SYMREF, which has type `rtx'
  659.      and is a `symbol_ref'.
  660.      This macro need not be defined if it does not need to output
  661.      anything.  The GNU assembler and most Unix assemblers don't
  662.      require anything.
  663. `ASM_OUTPUT_LABELREF (STREAM, NAME)'
  664.      A C statement (sans semicolon) to output to the stdio stream
  665.      STREAM a reference in assembler syntax to a label named NAME.
  666.      This should add `_' to the front of the name, if that is customary
  667.      on your operating system, as it is in most Berkeley Unix systems.
  668.      This macro is used in `assemble_name'.
  669. `ASM_OUTPUT_INTERNAL_LABEL (STREAM, PREFIX, NUM)'
  670.      A C statement to output to the stdio stream STREAM a label whose
  671.      name is made from the string PREFIX and the number NUM.
  672.      It is absolutely essential that these labels be distinct from the
  673.      labels used for user-level functions and variables.  Otherwise,
  674.      certain programs will have name conflicts with internal labels.
  675.      It is desirable to exclude internal labels from the symbol table
  676.      of the object file.  Most assemblers have a naming convention for
  677.      labels that should be excluded; on many systems, the letter `L' at
  678.      the beginning of a label has this effect.  You should find out what
  679.      convention your system uses, and follow it.
  680.      The usual definition of this macro is as follows:
  681.           fprintf (STREAM, "L%s%d:\n", PREFIX, NUM)
  682. `ASM_GENERATE_INTERNAL_LABEL (STRING, PREFIX, NUM)'
  683.      A C statement to store into the string STRING a label whose name
  684.      is made from the string PREFIX and the number NUM.
  685.      This string, when output subsequently by `assemble_name', should
  686.      produce the output that `ASM_OUTPUT_INTERNAL_LABEL' would produce
  687.      with the same PREFIX and NUM.
  688.      If the string begins with `*', then `assemble_name' will output
  689.      the rest of the string unchanged.  It is often convenient for
  690.      `ASM_GENERATE_INTERNAL_LABEL' to use `*' in this way.  If the
  691.      string doesn't start with `*', then `ASM_OUTPUT_LABELREF' gets to
  692.      output the string, and may change it.  (Of course,
  693.      `ASM_OUTPUT_LABELREF' is also part of your machine description, so
  694.      you should know what it does on your machine.)
  695. `ASM_FORMAT_PRIVATE_NAME (OUTVAR, NAME, NUMBER)'
  696.      A C expression to assign to OUTVAR (which is a variable of type
  697.      `char *') a newly allocated string made from the string NAME and
  698.      the number NUMBER, with some suitable punctuation added.  Use
  699.      `alloca' to get space for the string.
  700.      The string will be used as an argument to `ASM_OUTPUT_LABELREF' to
  701.      produce an assembler label for an internal static variable whose
  702.      name is NAME.  Therefore, the string must be such as to result in
  703.      valid assembler code.  The argument NUMBER is different each time
  704.      this macro is executed; it prevents conflicts between
  705.      similarly-named internal static variables in different scopes.
  706.      Ideally this string should not be a valid C identifier, to prevent
  707.      any conflict with the user's own symbols.  Most assemblers allow
  708.      periods or percent signs in assembler symbols; putting at least
  709.      one of these between the name and the number will suffice.
  710. `OBJC_GEN_METHOD_LABEL (BUF, IS_INST, CLASS_NAME, CAT_NAME, SEL_NAME)'
  711.      Define this macro to override the default assembler names used for
  712.      Objective C methods.
  713.      The default name is a unique method number followed by the name of
  714.      the class (e.g. `_1_Foo').  For methods in categories, the name of
  715.      the category is also included in the assembler name (e.g.
  716.      `_1_Foo_Bar').
  717.      These names are safe on most systems, but make debugging difficult
  718.      since the method's selector is not present in the name.
  719.      Therefore, particular systems define other ways of computing names.
  720.      BUF is an expression of type `char *' which gives you a buffer in
  721.      which to store the name; its length is as long as CLASS_NAME,
  722.      CAT_NAME and SEL_NAME put together, plus 50 characters extra.
  723.      The argument IS_INST specifies whether the method is an instance
  724.      method or a class method; CLASS_NAME is the name of the class;
  725.      CAT_NAME is the name of the category (or NULL if the method is not
  726.      in a category); and SEL_NAME is the name of the selector.
  727.      On systems where the assembler can handle quoted names, you can
  728.      use this macro to provide more human-readable names.
  729. File: gcc.info,  Node: Initialization,  Next: Macros for Initialization,  Prev: Label Output,  Up: Assembler Format
  730. How Initialization Functions Are Handled
  731. ----------------------------------------
  732.    The compiled code for certain languages includes "constructors"
  733. (also called "initialization routines")--functions to initialize data
  734. in the program when the program is started.  These functions need to be
  735. called before the program is "started"--that is to say, before `main'
  736. is called.
  737.    Compiling some languages generates "destructors" (also called
  738. "termination routines") that should be called when the program
  739. terminates.
  740.    To make the initialization and termination functions work, the
  741. compiler must output something in the assembler code to cause those
  742. functions to be called at the appropriate time.  When you port the
  743. compiler to a new system, you need to specify how to do this.
  744.    There are two major ways that GCC currently supports the execution of
  745. initialization and termination functions.  Each way has two variants.
  746. Much of the structure is common to all four variations.
  747.    The linker must build two lists of these functions--a list of
  748. initialization functions, called `__CTOR_LIST__', and a list of
  749. termination functions, called `__DTOR_LIST__'.
  750.    Each list always begins with an ignored function pointer (which may
  751. hold 0, -1, or a count of the function pointers after it, depending on
  752. the environment).  This is followed by a series of zero or more function
  753. pointers to constructors (or destructors), followed by a function
  754. pointer containing zero.
  755.    Depending on the operating system and its executable file format,
  756. either `crtstuff.c' or `libgcc2.c' traverses these lists at startup
  757. time and exit time.  Constructors are called in forward order of the
  758. list; destructors in reverse order.
  759.    The best way to handle static constructors works only for object file
  760. formats which provide arbitrarily-named sections.  A section is set
  761. aside for a list of constructors, and another for a list of destructors.
  762. Traditionally these are called `.ctors' and `.dtors'.  Each object file
  763. that defines an initialization function also puts a word in the
  764. constructor section to point to that function.  The linker accumulates
  765. all these words into one contiguous `.ctors' section.  Termination
  766. functions are handled similarly.
  767.    To use this method, you need appropriate definitions of the macros
  768. `ASM_OUTPUT_CONSTRUCTOR' and `ASM_OUTPUT_DESTRUCTOR'.  Usually you can
  769. get them by including `svr4.h'.
  770.    When arbitrary sections are available, there are two variants,
  771. depending upon how the code in `crtstuff.c' is called.  On systems that
  772. support an "init" section which is executed at program startup, parts
  773. of `crtstuff.c' are compiled into that section.  The program is linked
  774. by the `gcc' driver like this:
  775.      ld -o OUTPUT_FILE crtbegin.o ... crtend.o -lgcc
  776.    The head of a function (`__do_global_ctors') appears in the init
  777. section of `crtbegin.o'; the remainder of the function appears in the
  778. init section of `crtend.o'.  The linker will pull these two parts of
  779. the section together, making a whole function.  If any of the user's
  780. object files linked into the middle of it contribute code, then that
  781. code will be executed as part of the body of `__do_global_ctors'.
  782.    To use this variant, you must define the `INIT_SECTION_ASM_OP' macro
  783. properly.
  784.    If no init section is available, do not define
  785. `INIT_SECTION_ASM_OP'.  Then `__do_global_ctors' is built into the text
  786. section like all other functions, and resides in `libgcc.a'.  When GCC
  787. compiles any function called `main', it inserts a procedure call to
  788. `__main' as the first executable code after the function prologue.  The
  789. `__main' function, also defined in `libgcc2.c', simply calls
  790. `__do_global_ctors'.
  791.    In file formats that don't support arbitrary sections, there are
  792. again two variants.  In the simplest variant, the GNU linker (GNU `ld')
  793. and an `a.out' format must be used.  In this case,
  794. `ASM_OUTPUT_CONSTRUCTOR' is defined to produce a `.stabs' entry of type
  795. `N_SETT', referencing the name `__CTOR_LIST__', and with the address of
  796. the void function containing the initialization code as its value.  The
  797. GNU linker recognizes this as a request to add the value to a "set";
  798. the values are accumulated, and are eventually placed in the executable
  799. as a vector in the format described above, with a leading (ignored)
  800. count and a trailing zero element.  `ASM_OUTPUT_DESTRUCTOR' is handled
  801. similarly.  Since no init section is available, the absence of
  802. `INIT_SECTION_ASM_OP' causes the compilation of `main' to call `__main'
  803. as above, starting the initialization process.
  804.    The last variant uses neither arbitrary sections nor the GNU linker.
  805. This is preferable when you want to do dynamic linking and when using
  806. file formats which the GNU linker does not support, such as `ECOFF'.  In
  807. this case, `ASM_OUTPUT_CONSTRUCTOR' does not produce an `N_SETT'
  808. symbol; initialization and termination functions are recognized simply
  809. by their names.  This requires an extra program in the linkage step,
  810. called `collect2'.  This program pretends to be the linker, for use
  811. with GNU CC; it does its job by running the ordinary linker, but also
  812. arranges to include the vectors of initialization and termination
  813. functions.  These functions are called via `__main' as described above.
  814.    Choosing among these configuration options has been simplified by a
  815. set of operating-system-dependent files in the `config' subdirectory.
  816. These files define all of the relevant parameters.  Usually it is
  817. sufficient to include one into your specific machine-dependent
  818. configuration file.  These files are:
  819. `aoutos.h'
  820.      For operating systems using the `a.out' format.
  821. `next.h'
  822.      For operating systems using the `MachO' format.
  823. `svr3.h'
  824.      For System V Release 3 and similar systems using `COFF' format.
  825. `svr4.h'
  826.      For System V Release 4 and similar systems using `ELF' format.
  827. `vms.h'
  828.      For the VMS operating system.
  829.    The following section describes the specific macros that control and
  830. customize the handling of initialization and termination functions.
  831.